package ar.edu.unicen.pladema.vc1.model;

import java.util.HashMap;
import java.util.Observable;

public class GraphicAttributes extends Observable {
	public static final String LAST_ACTION = "lastaction";
	public static final String ZOOM = "zoom";
	public static final String SIZE_WIDTH = "s-w";
	public static final String SIZE_HEIGHT = "s-h";
	
	public static final String CLIENT_WIDTH = "c-w";
	public static final String CLIENT_HEIGHT = "c-h";
	
	public static final String OFFSET_X = "o-w";
	public static final String OFFSET_Y = "o-h";
	public static final String MAX_ITERATIONS = "maxIt";
	public static final String ELAPSED = "elapsed";
	public static final String FILE_NAME = "filename";
	
	private HashMap<String, String> values = new HashMap<String, String>();
	public GraphicAttributes add(String key, String value) {
		String prev = values.put(key, value);
		System.out.println("seteando '"+key+"'->"+value);
		if (prev == null) {
			iChange();
		} else if (!prev.equals(value)) {
			iChange();
		}
		return this;
	}
	public GraphicAttributes add(String key, int value) {
		return this.add(key, Integer.toString(value));
	}
	public GraphicAttributes add(String key, double value) {
		return this.add(key, Double.toString(value));
	}
	
	
	public String get(String key) {
		return values.get(key);
	}
	public int getInt(String key) {
		return Integer.parseInt(get(key));
	}
	public double getDouble(String key) {
		return Double.parseDouble(get(key));
	}
	private void iChange() {
		//System.out.println("I've changed");
		setChanged();
		notifyObservers();
	}




}
